package ase.assignment.sts.rmi.server;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

import ase.assignment.sts.api.CustomerHandler;
import ase.assignment.sts.beans.CustomerEntity;
import ase.assignment.sts.db.impl.HandlerFactoryJDBCImpl;
import ase.assignment.sts.utils.STSConstants;

public class CustomerHandlerRMIServerImpl extends UnicastRemoteObject implements
		CustomerHandler {
	private static final long serialVersionUID = -5703994586651028467L;

	protected CustomerHandlerRMIServerImpl() throws RemoteException {
		super();
	}

	private CustomerHandler getHandler() throws RemoteException {
		return new HandlerFactoryJDBCImpl().getCustomerHandler();
	}

	public void close(String username) throws RemoteException {
		getHandler().close(username);
	}

	public void create(CustomerEntity customer) throws RemoteException {
		getHandler().create(customer);
	}

	public CustomerEntity find(String username) throws RemoteException {
		return getHandler().find(username);
	}

	public boolean login(String username, String password)
			throws RemoteException {
				System.out.println("........remote login ");
		return getHandler().login(username, password);
	}

	public void update(CustomerEntity customer) throws RemoteException {
		getHandler().update(customer);
	}

}